package com.ozo.cloud.manage.feign;

import com.ozo.cloud.api.manage.feign.SysUserFeignClient;
import com.ozo.cloud.api.manage.vo.SysUserInfoVO;
import com.ozo.cloud.common.base.model.ResultVO;
import com.ozo.cloud.manage.service.ISysUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户服务调用
 *
 * @author qiangesoft
 * @date 2024-09-11
 */
@RequiredArgsConstructor
@RestController
public class UserFeignController implements SysUserFeignClient {

    private final ISysUserService sysUserService;

    @Override
    public ResultVO<Void> register(String username, String password, String nickname) {
        sysUserService.register(username, password, nickname);
        return ResultVO.success();
    }

    @Override
    public ResultVO<SysUserInfoVO> getByUsername(String username) {
        return ResultVO.success(sysUserService.getByUsername(username));
    }

    @Override
    public ResultVO<SysUserInfoVO> getByMobile(String mobile) {
        return ResultVO.success(sysUserService.getByMobile(mobile));
    }

    @Override
    public ResultVO<SysUserInfoVO> getByUserId(Long id) {
        return ResultVO.success(sysUserService.getByUserId(id));
    }

    @Override
    public ResultVO<List<SysUserInfoVO>> listAll() {
        return ResultVO.success(sysUserService.listAll());
    }

}
